package com.beans;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
public class UserBeans {
    @Bean(name = {"user","hu"})
    public User user1(){
        User user = new User();
        user.setId(1);
        user.setName("张三");
        return user;

    }

    @Bean
    public User user2(){
        User user = new User();
        user.setId(2);
        user.setName("李四");
        return user;

    }

    @Bean(name = "user3")
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
//    @Scope("prototype")
    public User user3(){
        User user = new User();
        user.setId(1);
        user.setName("java");
        return user;

    }
}
